package com.zp.soft2.StudentManagementSystem;

import java.util.ArrayList;
import java.util.Scanner;

public class StudentService {

    ArrayList<Student> studentList = new ArrayList();
    Scanner scanner = new Scanner(System.in);

    public void add(){
        Student student = new Student();
        System.out.println("请输入学生的姓名");

        String name = scanner.next();
        student.setName(name);
        System.out.println("请输入学生的年龄");
        int age = scanner.nextInt();
        System.out.println("请输入学生的学号");
        String Id = scanner.next();
        student.setAge(age);
        student.setId(Id);
        studentList.add(student);
        System.out.println(studentList);
    }
    public void printStudent(){

//        for (Student student : studentList) {
//
//            System.out.println("学生姓名为："+student.name+"-----学生年龄为："+student.eag);
//        }

        for (int i = 0; i < studentList.size(); i++) {
            Student student = studentList.get(i);
            System.out.println("学生姓名为："+student.getName() + "---学生年龄为：" + student.getAge()+"---学生ID为："+student.getId());
        }
    }




}
